package com.project.service.serveService.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.ServeBean;
import com.project.mapper.serveMapper.IServeMapper;
import com.project.service.serveService.IServeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ServeServiceImpl implements IServeService {
    @Autowired
    private IServeMapper serveMapper;

    @Override
    public void add(ServeBean serve, int storeId) {
        serveMapper.add(serve,storeId);
    }

    @Override
    public void del(int id) {
        serveMapper.del(id);
    }

    @Override
    public void update(int id, String time, int price) {
        serveMapper.update(id, time, price);
    }

    @Override
    public ServeBean findById(int id) {
        return serveMapper.findById(id);
    }

    @Override
    public PageInfo<ServeBean> findAll(int pageNO, int storeId) {
        PageHelper.startPage(pageNO,PAGESIZE);
        return PageInfo.of(serveMapper.findAll(storeId));
    }

    @Override
    public PageInfo<ServeBean> findByName(int pageNO, String name) {
        PageHelper.startPage(pageNO,PAGESIZE);
        return PageInfo.of(serveMapper.findByName(name));
    }

    @Override
    public void delAllByStore() {
        serveMapper.delAllByStore();
    }


    @Override
    public void addAllByStore() {
        serveMapper.addAllByStore();
    }
}
